<?php
namespace Admin\Controller;
use Think\Controller;
class CommentsController extends Controller {
    public function liuyan(){
    	$com=D('comments');
    	$list=$com->select();
    	//var_dump($list);
    	$count = $com->count();
        $Page       = new \Think\Page($count,2);//继承
        $show       = $Page->show();//展示
        $list = $com->limit($Page->firstRow.','.$Page->listRows)->select();
       
        $this->assign('count',$count);
        $this->assign('page',$show);
        $this->assign('list',$list);
        //var_dump($list);exit;


    	
    	$this->display();  
    }



	public function liuyandel(){
        $com=D('comments');
        
        $com->delete(I('get.lid'));
        $this->redirect('admin/comments/liuyan');

	}



     public function liuyanadd(){
          
         $com=D('comments');
        $coms= $com->find(I('get.lid'));
        $this->assign('coms',$coms);
        if(IS_POST){
            $data['reply']=I('reply');
            if(!$com->create($data)){
                echo $com->getError();
                exit;
            }else
            {   
                if($com->add())
                {
                    //$this->success('新增成功！',U('/admin/news/news',3));
                     echo "新增成功";
                }else
                {
                    $this->error('新增失败！');
                }
            }
        }

          $this->display();
        }
   
   
}